package com.xy.bizportdemo.controller;

import android.content.Context;
import android.content.res.AssetManager;

import com.example.messageutil.iface.IMenuProcessor;
import com.example.messageutil.iface.IMessageProcessor;
import com.example.messageutil.iface.ISmartSMSProcessor;

import java.lang.reflect.Method;

/**
 * Created by admin on 2017/8/31 0031.
 */

public class SmartSMSManager {
    private static final String TAG = "SmartSMSManager";
    private ISmartSMSProcessor mSmartSMSProcessor = null;
    private Context mContext = null;

    public void init() {
        if (mSmartSMSProcessor != null) {
            mSmartSMSProcessor.init(PluginManager.getInstance().getPluginContext());
        }
    }

    public IMessageProcessor loadMessageProcessor() {
        if (mSmartSMSProcessor != null) {
            return mSmartSMSProcessor.loadMessageProcessor();
        }

        return null;
    }

    public IMenuProcessor loadMenuProcessor() {
        if (mSmartSMSProcessor != null) {
            return mSmartSMSProcessor.loadMenuProcessor();
        }

        return null;
    }

    private static SmartSMSManager sManager = null;

    private SmartSMSManager(Context context) {
        mContext = context;
        Object object = PluginManager.getInstance().loadSMSProcessor(context);
        if (object != null) {
            mSmartSMSProcessor = (ISmartSMSProcessor) object;
        }
    }

    public static SmartSMSManager getInstance() {
        return sManager;
    }

    public static SmartSMSManager getInstance(Context context) {
        if (sManager == null) {
            synchronized (SmartSMSManager.class) {
                if (sManager == null) {
                    sManager = new SmartSMSManager(context);
                }
            }
        }

        return sManager;
    }
}
